//
//  CollectionViewControllerBase.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2020/9/5.
//  Copyright © 2020 moon. All rights reserved.
//

#import "CollectionViewControllerBase.h"
#import "EmptyDataView.h"

@interface CollectionViewControllerBase ()

@end

@implementation CollectionViewControllerBase
+ (MKTFuncItem *)funcItem{
    return [MKTFuncItem funcWithName:NSStringFromClass(self) viewControllerClass:self];
}
- (id)init{
    if(self=[super init]){
        self.tabBarItem.title = [self.class funcItem].name;
        self.title = [self.class funcItem].name; 
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.collectionView.backgroundColor = [UIColor mk_colorWithLight:[UIColor whiteColor]];
    if (@available(iOS 11.0, *)) {
        self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways;
        //alawys时，adjustedContentInset=contentInsets+safeAreaInsets；
        //auto时，adjustedContentInset.top/bottom=contentInsets+safeAreaInsets.top/bottom
    } else {
        // Fallback on earlier versions
    }
    self.model = [[MKUICollectionViewModel alloc] initWithCollectionView:self.collectionView];
    self.model.emptyBackgroundViewClass = [EmptyDataView class];
    NSLog(@"viewDidLoad:%@",NSStringFromClass(self.class));
}
- (void)viewWillLayoutSubviews{
    [super viewWillLayoutSubviews];
//    if (@available(iOS 11.0, *)) {
////        UIEdgeInsets safeAreaInsets = self.view.safeAreaInsets;
////        self.collectionView.adjustedContentInset;
//    } else {
//    }
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    NSLog(@"viewWillAppear:%@,animated:%@",NSStringFromClass(self.class),@(animated));
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    NSLog(@"viewDidAppear:%@,animated:%@",NSStringFromClass(self.class),@(animated));
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    NSLog(@"viewWillDisappear:%@,animated:%@",NSStringFromClass(self.class),@(animated));
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    NSLog(@"viewDidDisappear:%@,animated:%@",NSStringFromClass(self.class),@(animated));
}
@end
